<?php

?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
    <link rel="stylesheet" href="/shop/shop.css" />
    
</head>
<body>
    <div class="container" >
        <?php 
            require_once("userTip.php");
            require_once("productSelect.php");

        ?>
        <div class="products" >
        <?php
            foreach ($productArr as $key => $p) {
                echo "<div class=\"item\" >
                <div class=\"img\" >
                    <img src=\"" . $p["p_image_url"] . "\" alt=\"no image\">
                </div>
                <div class=\"desc\" >
                    <div><a href=\"#\">" . $p["p_name"] . "</a></div>
                    <div class=\"ac\" >
                        <span class=\"p\" >￥ " . $p["p_price"] . "</span>
                        <a href=\"/shop/addCart.php?pid=" . $p["p_id"] . "\" class=\"add\" >加入购物车</a>
                    </div>
                </div>
            </div>";
            }
        ?>

        </div>

        <div class="page" >
            <?php
                $preNum = $pageNum-1;
                $nextNum = $pageNum+1;
                if($pageNum > 1){
                    echo "<a href=\"/shop/index.php?pageNum={$preNum}\">上一页</a>";
                }
                echo "<a href=\"/shop/index.php?pageNum={$pageNum}\">{$pageNum}</a>";
                if($pageNum < $totalPage){
                    echo "<a href=\"/shop/index.php?pageNum={$nextNum}\">下一页</a>";
                }
            ?>
        </div>
    </div>
</body>
</html>